package controller.categories;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.hibernate.Query;
import org.hibernate.Session;

import categories.Category;

import utils.HibernateUtils;

public class ListCategoriesAction extends Action{
	
private static Session s = null;
	
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
			
		s = HibernateUtils.getSession();
		
		Query q = s.createQuery("FROM Category ");
		
		ArrayList<Category> list =(ArrayList<Category>) q.list();
			
		return mapping.findForward("succes");
	}

}
